/**
 * @Title: Logic.java
 * @Package: com.jason.bluetooth.fingerprint.logic
 * @Descripton: TODO
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2014年10月21日 上午9:58:26
 * @Version: V1.0
 */
package net.hzlj.platform.enterprise.task;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.builder.PostFormBuilder;

import net.hzlj.platform.enterprise.beans.resp.RespBaseBean;

import cn.finalteam.okhttpfinal.HttpCycleContext;
import cn.finalteam.okhttpfinal.RequestParams;

/**
 * @ClassName: Task
 * @Description: 业务处理的基类
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2015-7-28 13:48:43
 */
public abstract class Task<T> {

	private static final String TAG = Task.class.getSimpleName();

	/** 任务类型,用来区分不同任务*/
	public int type = -1;
	/** 回调监听器*/
	public TaskListener listener = null;

	public HttpCycleContext httpCycleContext;

	/** 是否成功 */
	public boolean isSuccess = false;
	/** 请求参数 */
	public Object param = null;
	/** 响应数据 */
	public RespBaseBean<T> resData = null;
	public Object respData = null;
	public Object paramObject;
	/** 返回码*/
	public int rspCode = 0;

	public RequestParams params;

	public PostFormBuilder postFormBuilder;

	public String url;//请求链接

	/** 返回码描述 */
	public String rspDesc = "服务器返回失败";

	public Class<T> clas;

	public Task(){

	}

	public Task(TaskListener listener){
		this.listener = listener;
		params = new RequestParams();
		postFormBuilder = OkHttpUtils.post();
	}

	public Task(TaskListener listener,HttpCycleContext httpCycleContext){
		this.listener = listener;
		this.httpCycleContext = httpCycleContext;
		if (httpCycleContext == null){
			params = new RequestParams();
		}else {
			params = new RequestParams(httpCycleContext);
		}
		postFormBuilder = OkHttpUtils.post();
	}

	public Task(TaskListener listener,Class<T> cla){
		this.listener = listener;
		params = new RequestParams();
		postFormBuilder = OkHttpUtils.post();
		this.clas = cla;
	}

	public Task(TaskListener listener,HttpCycleContext httpCycleContext,Class<T> cla){
		this.listener = listener;
		this.httpCycleContext = httpCycleContext;
		if (httpCycleContext == null){
			params = new RequestParams();
		}else {
			params = new RequestParams(httpCycleContext);
		}
		postFormBuilder = OkHttpUtils.post();
		this.clas = cla;
	}

	/***
	 * 方法执行类
	 * @Return 
	 */
	public abstract void execute();

}
